package org.example.short_link.project.controller;

import lombok.RequiredArgsConstructor;
import org.example.short_link.project.common.convention.result.Result;
import org.example.short_link.project.common.convention.result.Results;
import org.example.short_link.project.service.UrlTitleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequiredArgsConstructor
public class UrlTitleController {

    private final UrlTitleService urlTitleService;


    @GetMapping("/api/short-link/v1/title")
    public Result<String> getUrlTitleByID(@RequestParam("url") String url){
        return Results.success(urlTitleService.getTitleByUrl(url));
    }



}
